#ifndef  _Mmc_H_
#define  _Mmc_H_

#ifdef _cplusplus
extern "c"{
#endif

#include "MmcDef.h"
#include "DebugMmc.h"
#include "common_Define.h"
#include "driver_uart.h"
#include "Queue.h"
#include "Message.h"
#include "SwTimer.h"
#include "Ipmb.h"
#include "Sensor.h"
#include "TransferDriver.h"
#include "Led.h"
#include "Sdr.h"
#include "ConfigInfo.h"
#include "IicCrb.h"
#include "E_Key.h"
#include "Command_Define.h"

typedef struct _tagMmc
{
	uint8	m_isFeedWd:1;
	uint8	m_isTimerDisable:1;

	uint8	m_FirmwareMasterRev;
	uint8	m_FirmwareSubRev;
	uint8	m_IpmiRev;
	uint8	m_DeviceRev;
	
	uint8 	m_ReceiverAddress; 		//Event Receiver Address
	uint8 	m_ReceiverLun; 			//Event Receiver Lun

	FruCtrlCap	m_FruCtrlCapMask;
	
	TimerManager	m_TimerManager;

	Ipmb			m_Ipmb;
	IicCrb			m_ReqCrb;
	IicCrb			m_RspCrb;
	IicTransfer		m_IicTransfer;
	
	Ipmb			m_UartIpmb;
	IicCrb			m_UartReqCrb;
	IicCrb			m_UartRspCrb;
	UartTransfer	m_UartTransfer;


	Queue m_msgQueue;
	Message m_msgQueuePool[MSG_QUEUE_SIZE];
	
	Led			m_BlueLed;
	Led			m_Led1;

	Sensor		m_Sensor[MAX_SENSOR_COUNT];
	Sensor*				m_pSensor[MAX_SENSOR_COUNT];
    DevLocatorRecord 	m_DevicLocatorRecord;	
    CompactSensorRecord	m_HandleCompactSensorRecord;
	
	uint8				m_FruBuff[FRU_BUFFER_SIZE];
	RecordHeader* 		m_pFruRecordArray[6];
	FruInfo				m_FruInfo;
	
	FruInfo				m_ConfigInfo;
	RecordHeader* 		m_pConfigRecordArray[6];
	uint8				m_SdrBuff[SDR_BUFFER_SIZE];
	
	Sdr					m_Sdr;
	SdrHeader*			g_pSdrHeader[MAX_SDR_COUNT];
	
	SwTimer				m_Timer;
	E_keying            m_E_Keying;
	
	Queue 	m_reqDataQueue;
	ReqData m_reqDataPool[MAX_REQDATA_COUNT];
	
	Queue 	m_PayloadReqDataQueue;
	ReqData m_PayloadReqDataPool[MAX_REQDATA_COUNT];
	
}Mmc;
extern Mmc g_Mmc;

extern unsigned char  g_Owerner_IPMB_Addr;
extern unsigned char  g_Owerner_IPMB_Type;
extern unsigned char  g_Owerner_Sit_Num;
extern unsigned char  g_Owerner_SIT_TYPE;
extern uint8 gWatchDogSwitch;
extern uint8 gDelay;

int Mmc_Init(Mmc* pMmc);
void Mmc_Run(Mmc* pMmc);
Sensor* Mmc_GetSensor(uint8 sensorNum);
Led* Mmc_GetLed(uint8 ledType);

inline Sensor* Mmc_GetHandleSensor(){return &g_Mmc.m_Sensor[0];};

 //regist 2 iic driver's call back function
void MMC_revI2cRetn(char chanNum,char EventInd);
void Mmc_SensorReset(void);
void Mmc_SetEventReceiver(uint8 eventReceiver, uint8 lun);
Bool Mmc_FreDevTest(uint16 offset, uint16 len);
int Mmc_WriteFruDevice(FruInfo* pFruInfo, uint32 offset, const uint8* pData, uint16 len);
int Mmc_ReadFruDevice(FruInfo* pFruInfo, uint32 offset, uint8* pData, uint16 len);


#ifdef _cplusplus
}
#endif

#endif             



